/*      $Id: HTTPMessage.java 817 2008-09-01 20:15:56Z phrakt $    */
/*
 * Copyright (c) 2007 Jean-Francois Brousseau <phrakt@gmail.com>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. The name of the author may not be used to endorse or promote products
 *    derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
 * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
package ca.terraquati.canopy.http;

import java.util.Set;


/**
 * An interface to represent HTTP messages.
 *
 *
 * @author Jean-Fran&ccedil;ois Brousseau
 */
public interface HTTPMessage
{
	/**
	 * An enumeration of known HTTP versions.
	 */
	public enum Version {
		HTTP_0_9(0, 9),
		HTTP_1_0(1, 0),
		HTTP_1_1(1, 1);

		private final int    versionMajor;
		private final int    versionMinor;

		Version(final int major, final int minor)
		{
			this.versionMajor = major;
			this.versionMinor = minor;
		}

		/**
		 * Generate a string version of the HTTP version represented
		 * by this object.  The generated string has the 'HTTP/'
		 * prefix.
		 */
		public String toString()
		{
			return "HTTP/" + this.versionMajor + "." +
			    this.versionMinor;
		}
	};


	/**
	 * Gets the HTTP header whose name is specified in <code>name</code>.
	 *
	 * @return an {@HTTPHeader} object representing the header on success,
	 *         or <code>null</code> on failure.
	 */
	public HTTPHeader getHeader(final String name);

	/**
	 * Gets all the headers set on the HTTP message represented by this
	 * object.
	 *
	 * @return a set of all the headers for this message
	 */
	public Set<HTTPHeader> getHeaders();

	/**
	 * Gets the version of the HTTP message represented by this object.
	 *
	 * @return this message's HTTP version
	 */
	public Version getVersion();

	/**
	 * Sets the value of the HTTP header whose name is specified in
	 * <code>name</code> to the value specified in <code>value</code> for
	 * the HTTP message represented by this object.
	 *
	 * @param   name   the name of the HTTP header to set
	 * @param   value  the value associated with the HTTP header
	 */
	public void setHeader(final String name, final String value);

	/**
	 * Sets the HTTP headers for the HTTP message represented by this
	 * object to the set of headers specified in <code>headers</code>.
	 *
	 * @param   headers   the HTTP headers to set for this message
	 */
	public void setHeaders(final Set<HTTPHeader> headers);

	/**
	 * Sets the HTTP version of the message represented by this object
	 * to the version <code>version</code>.
	 *
	 * @param   version   the HTTP message's version number
	 */
	public void setVersion(final Version version);
}
